package com;

import java.util.Scanner;

/**
 * description 暂无描述
 * author 燚山
 * time 2023/3/11 18:45
 */
public class powernode {
    public static void main(String[] args) {
        Scanner input= new Scanner(System.in);
        String[] name = new String[100];
        String[] idCard = new String[100];
        int [] gender = new int[100];
        String[] address = new String[100];
        flag:for (int i = 0;;) {
            System.out.println("************请输入如下选项************:");
            System.out.println("             1.信息录入");
            System.out.println("             2.信息查询");
            System.out.println("             3.信息修改");
            System.out.println("             4.信息删除");
            System.out.println("             5.退出");
            System.out.print("请输入你的选择:");
            int num = input.nextInt();
           flag2:switch (num){
                case 1:
                    System.out.println("开始录入公民信息:");
                    System.out.print("(1)请输入姓名:");
                    name[i] = input.next();
                    System.out.print("(2)请输入身份证号:");
                    idCard[i] = input.next();
                    System.out.print("(3)请输入性别(1.男:2.女):");
                    gender[i] = input.nextInt();
                    System.out.print("(4)请输入地址:");
                    address[i] = input.next();
                    System.out.println("录入成功");
                    i++;
                    break;
                case 2:
                    System.out.println("所有人信息列表如下:");
                    for (int j = 0; j < i; j++) {
                        if (idCard[j]!=null) {
                            System.out.println(name[j]+"\t"+idCard[j]+"\t"+(gender[j]==1?"男":"女")+"\t"+address[j]);
                        }
                    }
                    break;
                case 3:
                    System.out.println("开始信息修改:");
                    int n = -1;
                    System.out.print("请输入需要修改人身份证:");
                    String card = input.next();
                    for (int j = 0; j <i ; j++) {
                        if (idCard[j].equals(card)){
                            n=j;
                            break ;
                        };
                    }
                    if (n==-1){
                        System.out.println("您输入的身份证号有误,请重新输入:");
                        break flag2;
                    }
                    System.out.println("开始信息修改");
                    System.out.print("请输入姓名:");
                    name[n]= input.next();
                    System.out.print("请输入性别:");
                    gender[n]=input.nextInt();
                    System.out.print("请输入地址:");
                    address[n]= input.next();
                    break;
                case 4:
                    System.out.println("开始信息删除:");
                    int n1 = -1;
                    System.out.print("请输入需要删除人身份证:");
                    String card1 = input.next();
                    for (int j = 0; j <i ; j++) {
                        if (idCard[j].equals(card1)){
                            n1=j;
                            break ;
                        };
                    }
                    if (n1==-1){
                        System.out.println("您输入的身份证号有误,请重新输入:");
                        break flag2;
                    }
                    idCard[n1]=null;
                    break;
                case 5:
                    break flag;
            }
        }
    }
}
